{extend name="../../index/view/public/mlay" /}
{block name="title"}修改资料{/block}
{block name="style"}
<style></style>
{/block}
{block name="header"}
{include file="public/header" /}
{/block}
{block name="container"}
{eq name="$user.auth" value="0"}
<div class="weui-form" style="padding: 0;">
	<div class="weui-form__control-area">
		<div class="weui-cells__group weui-cells__group_form">
			<div class="weui-cells__title">{$Request.param.tips|default="个人资料"}</div>
			<div class="weui-cells weui-cells_form">
				<div class="weui-cell _getinfo">
					<div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
					<div class="weui-cell__bd">
						<input class="weui-input" name="realname" placeholder="填写本人真实姓名"
							value="{$user.realname|default=''}">
					</div>
				</div>
				<div class="weui-cell _getinfo mobile">
					<div class="weui-cell__hd"><label class="weui-label">电话</label></div>
					<div class="weui-cell__bd">
						<input id="mobile" class="weui-input" name="mobile" placeholder="填写本人的电话号码" type="number"
							pattern="[0-9]*" value="{$user.mobile|default=''}">
					</div>
				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd"><label class="weui-label">身份证</label></div>
					<div class="weui-cell__bd">
						<input class="weui-input" name="idcard" placeholder="填写18位身份证号" type="text"
							value="{$user.idcard|default=''}">
					</div>
				</div>
				<div class="weui-cells__title">推荐人：{$user.push_user|default=''}</div>
				<div class="weui-cell">
					<div class="weui-cell__hd"><label class="weui-label">推荐人ID</label></div>
					<div class="weui-cell__bd">
						<input class="weui-input" name="pid" placeholder="填写推荐人的ID号" type="text"
							value="{$user.pid|default='0'}">
					</div>
				</div>
			</div>
		</div>
	</div>
	{notempty name="service"}
	<div class="weui-form__tips-area">
		<p class="weui-form__tips">
			所属网点：{$service.bank}【{$service.branch}】。<br>如需修改，请联系管理员。
		</p>
	</div>
	{/notempty}
	<div class="weui-form__opr-area">
		<a class="weui-btn weui-btn_primary bgv" href="javascript:" id="to-post">提交</a>
	</div>
	<div class="weui-form__tips-area">
		<p class="weui-form__tips">
			基本信息是系统所需，请准确填写!
		</p>
	</div>
</div>
{else/}
<div class="weui-msg">
	<div class="weui-msg__icon-area"><i class="weui-icon-success weui-icon_msg"></i></div>
	<div class="weui-msg__text-area">
		<h2 class="weui-msg__title">认证成功</h2>
		<p class="weui-msg__desc">如需更改，请联系客服人员！</p>
	</div>
	<div class="weui-msg__extra-area">
		<div class="weui-form-preview">
			<div class="weui-form-preview__bd">
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label">姓名</label>
					<span class="weui-form-preview__value">{$user.realname|default=''}</span>
				</div>
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label">电话</label>
					<span class="weui-form-preview__value">{$user.mobile|default=''}</span>
				</div>
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label">身份证号</label>
					<span class="weui-form-preview__value">{$user.idcard|default=''}</span>
				</div>
				<div class="weui-form-preview__item">
					<label class="weui-form-preview__label">推荐人</label>
					<span class="weui-form-preview__value">{$user.push_user|default=''}</span>
				</div>
			</div>
		</div>
	</div>
</div>

{/eq}
{/block}
{block name="copyright"}{/block}
{block name="script"}
<script>
	$(document).ready(function() {
		$("#to-post").on("click", function() {
			var data = {
				realname: $("input[name='realname']").val(),
				mobile: $("input[name='mobile']").val(),
				idcard: $("input[name='idcard']").val(),
				address: $("input[name='address']").val(),
				pid: $("input[name='pid']").val(),
				__token__: $("input[name='__token__']").val(),
			}
			$.post('', data, function(res) {
				if (res.code == 0) {
					weui.topTips(res.msg, {
						className: 'warning'
					});
				} else {
					weui.topTips(res.msg, {
						className: 'success'
					});
					var golink = function() {
						window.location.href = res.url;
					}
					setTimeout(golink, 500);
				}
			})
		})
		$("#openid").on("click", function() {
			$.post("{:url('api/index/getopenid')}", '', function(res) {
				if (res.code == 0) {
					weui.topTips(res.msg, {
						className: 'warning'
					});
				} else {
					weui.topTips(res.msg, {
						className: 'success'
					});
					$("input[name='address']").val(res.data);
				}
			});
		})
	})
</script>
{/block}
